- Agregamos columnas y especificamos su contenido.
f1 <- mutate(flights, gain = arr_delay - dep_delay,
speed = gain/air_time * 60)
head(f1)
## # A tibble: 6 × 21
## year month day dep_time sched_dep_time dep_delay arr_time sched_arr_time
## <int> <int> <int> <int> <int> <dbl> <int> <int>
## 1 2013 1 1 517 515 2 830 819
## 2 2013 1 1 533 529 4 850 830
## 3 2013 1 1 542 540 2 923 850
## 4 2013 1 1 544 545 -1 1004 1022
## 5 2013 1 1 554 600 -6 812 837
## 6 2013 1 1 554 558 -4 740 728
## # … with 13 more variables: arr_delay <dbl>, carrier <chr>, flight <int>,
## # tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
## # hour <dbl>, minute <dbl>, time_hour <dttm>, gain <dbl>, speed <dbl>
# ¿Qué hace diferente transmmute()?
transmute(flights, gain = arr_delay - dep_delay,
gain_per_hour = gain/(air_time/60))